package oppsa.controller;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Properties 
{

	private java.util.Properties properties = new java.util.Properties();
	private FileInputStream fis;

	public java.util.Properties loadProperties(String propertiesFileLocation)
    {
 
    	try 
    	{
            //load a properties file
    		fis = new FileInputStream(propertiesFileLocation);
    		this.properties.load(fis);
 
               //get the property value and print it out
 
    	}  
    	catch (IOException ex) 
    	{
    		System.err.println("Ops : "+ ex.getMessage());
        }
    	return this.properties;
 
    }
	
	public java.util.Properties getProperties() 
	{
		return properties;
	}

	public void setProperties(java.util.Properties properties) 
	{
		this.properties = properties;
	}

	public FileInputStream getFis() {
		return fis;
	}

	public void setFis(FileInputStream fis) {
		this.fis = fis;
	}

	public void setProperties(String key, String value, String propertiesFileLocation)
    {
 
    	try 
    	{
    		//set the properties value
    		properties.setProperty(key, value);
 
    		//save properties to project root folder
    		properties.store(new FileOutputStream(propertiesFileLocation), null);
 
    	} catch (IOException ex) 
    	{
    		System.err.println("Ops : "+ ex.getMessage());
        }
    }
}
